package producer

import (
	ktp "common/kafkatimer/producer"
	log "common/log4go"
	"iot-bridge/iot_cmd_up/distribute/conf"
)

var (
	p *ktp.Producer
)

func Init() error {
	var err error
	p, err = ktp.NewProducer(conf.Conf.Producer.Addrs)
	if err != nil {
		return err
	}
	return nil
}
func Close() {
	p.Close()
}

func Send(topic, key, data string) (err error) {
	err = p.Send(topic, key, data)
	if err != nil {
		log.Error("p.Send(%s, %s, %s) error(%v)", topic, key, data, err)
	}
	return nil
}
